<template>
  <a-modal
    title="新增"
    :maskClosable="false"
    :width="1050"
    placement="right"
    :closable="true"
    @cancel="onClose"
    :footer="null"
    :visible="managerInfoAddVisiable"
  >
    <a-form :form="form">
      <a-row>
        <a-col :md="12" :sm="24"
          ><a-form-item label="拓展经理角色" v-bind="formItemLayout">
            <a-select v-decorator="[
                'agentName',
                { rules: [{ required: true, message: '不能为空' }] },
              ]">
              <a-select-option value="40">40-拓展经理</a-select-option>
              <a-select-option value="41">41-拓展经理审核员</a-select-option>
            </a-select>
              </a-form-item>
              </a-col>
        <a-col :md="12" :sm="24"
          ><a-form-item label="手机号" v-bind="formItemLayout">
            <a-input
              v-decorator="[
                'managerPhone',
                { rules: [{ required: true, message: '不能为空' }] },
              ]"
            /> </a-form-item
        ></a-col>
      </a-row>
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="姓名" v-bind="formItemLayout">
            <a-input
              v-decorator="[
                'managerName',
                { rules: [{ required: true, message: '不能为空' }] },
              ]"
            />
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item label="员工号" v-bind="formItemLayout">
            <a-input
              v-decorator="['managerId']"
            /> </a-form-item
        ></a-col>
      </a-row>
      <a-row>
        <a-col :md="12" :sm="24"
          ><a-form-item label="地区代码－省" v-bind="formItemLayout">
            <a-select v-decorator="['province']" @change="handleChange">
              <a-select-option value="00"> 营业执照 </a-select-option>
            </a-select>
          </a-form-item></a-col
        >
        <a-col :md="12" :sm="24"
          ><a-form-item label="地区代码－市" v-bind="formItemLayout">
            <a-select v-decorator="['city']" @change="handleChange">
              <a-select-option value="00"> 营业执照 </a-select-option>
            </a-select>
            </a-form-item></a-col>
      </a-row>
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="地区代码－区" v-bind="formItemLayout">
            <a-select v-decorator="['area']" @change="handleChange">
              <a-select-option value="00"> 营业执照 </a-select-option>
            </a-select>
            </a-form-item>
            </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item label="收单机构类型" v-bind="formItemLayout">
            <a-select v-decorator="['artifCertType']" @change="handleChange">
                  <a-select-option value="BANK"> 银行 </a-select-option>
              <a-select-option value="AGENT"> 代理商 </a-select-option>
            </a-select>
          </a-form-item>
          </a-col>
      </a-row>
      <!-- 根据收单机构类型 动态变化-->
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="收单机构" v-bind="formItemLayout">
            <a-input v-decorator="['signInstIdOrg']" /> </a-form-item
        ></a-col>
        <a-col :md="12" :sm="24"
          ><a-form-item label="收单机构" v-bind="formItemLayout">
            <a-input v-decorator="['signInstIdAgent']" /> </a-form-item
        ></a-col>
      </a-row>
    </a-form>
    <div class="drawer-bootom-button">
      <a-button @click="handleSubmit" type="primary" :loading="loading"
        >保存
      </a-button>
      <a-button style="margin-left: 0.8rem" @click="onClose">取消</a-button>
    </div>
  </a-modal>
</template>
<script>
const formItemLayout = {
  labelCol: { span: 6 },
  wrapperCol: { span: 15 },
};
export default {
  name: "ManagerInfoAdd",
  props: {
    managerInfoAddVisiable: {
      default: false,
    },
  },
  data() {
    return {
      managerInfo: {},
      loading: false,
      roleData: [],
      formItemLayout,
      form: this.$form.createForm(this),
    };
  },
  methods: {
    reset() {
      this.loading = false;
      this.form.resetFields();
    },
    onClose() {
      this.reset();
      this.$emit("close");
    },
    handleSubmit() {
      this.form.validateFields((err, values) => {
        if (!err) {
          this.setManagerInfoFields();
          this.loading = true;
          this.managerInfo.roleId = this.managerInfo.roleId.join(",");
          // this.$post('managerInfo', {
          //   ...this.managerInfo
          // }).then((r) => {
          //   this.reset()
          //   this.$emit('success')
          // }).catch(() => {
          //   this.loading = false
          // })
        }
      });
    },
handleChange(){},
    setManagerInfoFields() {
      let values = this.form.getFieldsValue(["dstChannelId", "dstChannelName"]);
      if (typeof values !== "undefined") {
        Object.keys(values).forEach((_key) => {
          this.managerInfo[_key] = values[_key];
        });
      }
    },
  },
  watch: {},
};
</script>
